#-*- coding:utf-8 -*-
import os
import inspect
import maya.cmds as cmds
import pymel.core as pm
import sys


file_path = inspect.getfile(lambda: None)
mz_tool_path = os.path.dirname(os.path.dirname(file_path))
# mz_tool_path = r'\\192.168.1.248\cgteamwork3\Maya_plugin\maya_pipeline'
sys.path.insert(0,mz_tool_path)

def init_mz_tool():

    #import sys

    #mz_tool_path = r'E:\PycharmOut\timeaxis\maya_pipeline'
    # mz_tool_path = r'C:\Users\laozhang\Documents\maya\2018\scripts'
    #sys.path.insert(0,mz_tool_path)
    # from test import ad
    #from maya_project_control import maya_ui 


    main_window = pm.language.melGlobals['gMainWindow']
    menu_obj = 'TimeVFX_Tools'
    menu_label = 'TimeVFX_Tools'

    #m = maya_ui

    #pm.deleteUI(pm.menu('MZToolMenu',e=True,deleteAllItems=True)) delete 

    if pm.menu(menu_obj,label=menu_label,exists=True,parent=main_window):
        pm.deleteUI(pm.menu(menu_obj,e=True,deleteAllItems=True))
    mz_tool_menu = pm.menu(menu_obj,label=menu_obj,parent=main_window,tearOff=True)

    # pm.menuItem(label=u'创建/载入工程',command="maya_ui()",parent=mz_tool_menu,tearOff=True)
    pm.menuItem(label=u'展开工具面板',command="maya_tool()",parent=mz_tool_menu,tearOff=True)
    # pm.menuItem(label=u'跟踪',subMenu=True,parent=mz_tool_menu,tearOff=True)
    # pm.menuItem(label=u'to',command="maya_ui()")

    # pm.menuItem(label='MOD',subMenu=True,parent=mz_tool_menu,tearOff=True)
    # pm.menuItem(label='ANI',subMenu=True,parent=mz_tool_menu,tearOff=True)
    # pm.menuItem(label='ENV',subMenu=True,parent=mz_tool_menu,tearOff=True)
    # pm.menuItem(label='EFX',subMenu=True,parent=mz_tool_menu,tearOff=True)
#cmds.evalDeferred("import pymel.core as pm ")

def test():
    #import pymel.core as pm
    #cam = pm.camera('laozhang')
    #cmds.polysphere()
    window = cmds.window( title="Long Name", iconName='Short Name', widthHeight=(200, 55) )
    cmds.columnLayout( adjustableColumn=True )
    cmds.button( label='Do Nothing' )
    cmds.button( label='Close', command=('cmds.deleteUI(\"' + window + '\", window=True)') )
    cmds.setParent( '..' )
    cmds.showWindow( window )

# cmds.evalDeferred('from maya_project_control import maya_ui') 
cmds.evalDeferred('from main_window import maya_tool') 
cmds.evalDeferred('init_mz_tool()') 

